package com.pig4cloud.pig.village.collect.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.village.api.entity.CollectInfo;
import com.pig4cloud.pig.village.collect.service.ICollectInfoService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author limbray.li
 * @date 2021/7/27
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/collectInfo")
@Api(value = "collectInfo", tags = "福利金发放统计")
public class CollectInfoController {
	@Resource
	private ICollectInfoService collectInfoService;

	@GetMapping("/list")
	public R<IPage<CollectInfo>> list(Integer pageNum, Integer pageSize) {
		return R.ok(collectInfoService.page(new Page(pageNum,pageSize)));
	}

	@GetMapping("/get")
	public R<CollectInfo> get(Long id) {
		return R.ok(collectInfoService.getById(id));
	}

	@PutMapping("/deleteById")
	public R delete(Long id) {
		return R.ok(collectInfoService.removeById(id));
	}

	@PostMapping("/add")
	public R add(@RequestBody CollectInfo collectInfo) {
		return R.ok(collectInfoService.save(collectInfo));
	}
}
